<template>
  <div class="header">
    <van-icon name="arrow-left" class="icon" @click="goBack" />
    <div>
      {{ title }}
    </div>
    <div class="edit" v-if="edit" @click="handelEdit">
     {{ cartStore.edit ?"编辑":"完成" }}
    </div>
  </div>
</template>

<script setup>
import { useRouter } from "vue-router";
import { useCartStore } from "../../../store/CartSore";

defineProps({
  title: "",
  edit:Boolean
});
const router = useRouter();
const cartStore=useCartStore()
const goBack = () => {
  router.back();
};
const handelEdit=()=>{
  if(cartStore.cartList.length){
    cartStore.changeEdit()
    cartStore.changeDelete()
  }
  else{
    showFailToast('请选择商品');
  }
}
</script>

<style scoped lang="less">
.header {
  background-color: #fff;
  height: 40px;
  font-size: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
  border-bottom: 1px solid #d7d7d7;
  .edit{
    font-size: 16px;
    position: absolute;
    right: 15px;
    font-weight: normal;
  }
  .icon {
    position: absolute;
    left: 10px;
  }
}
</style>
